import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true,
  },
  {
    path: '/403',
    name: '403',
    component: () => import('@/views/403'),
    hidden: true,
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404'),
    hidden: true,
  },
]
export const asyncRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    meta: {
      title: '首页',
      icon: 'home-4-line',
      affix: true,
    },
    children: [
      {
        path: 'index',
        name: 'Index',
        component: () => import('@/views/index'),
        meta: {
          title: '首页',
          icon: 'home-4-line',
          affix: true,
        },
      },
    ],
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user',
    meta: {
      title: '用户',
      icon: 'user-line',
    },
    children: [
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/user/index'),
        meta: {
          title: '用户管理',
          icon: 'user-line',
        },
      },
    ],
  },
  {
    path: '/article',
    component: Layout,
    redirect: '/article',
    meta: {
      title: '文章管理',
      icon: 'article-fill',
    },
    children: [
      {
        path: 'createArticle/:id?',
        name: 'createArticle',
        component: () => import('@/views/article/createArticle'),
        meta: {
          title: '创建文章',
          icon: 'add-box-line',
        },
      },
      {
        path: 'article',
        name: 'article',
        component: () => import('@/views/article/index'),
        meta: {
          title: '文章列表',
          icon: 'article-line',
        },
      },
      {
        path: 'recycle',
        name: 'recycle',
        component: () => import('@/views/article/recycle'),
        meta: {
          title: '回收站',
          icon: 'recycle-line',
        },
      },
    ],
  },
  {
    path: '/comment',
    component: Layout,
    redirect: '/comment',
    meta: {
      title: '评论管理',
      icon: 'creative-commons-fill',
    },
    children: [
      {
        path: 'comment',
        name: 'comment',
        component: () => import('@/views/comment/index'),
        meta: {
          title: '评论列表',
          icon: 'creative-commons-fill',
        },
      },
    ],
  },
  {
    path: '/like',
    component: Layout,
    redirect: '/like',
    meta: {
      title: '点赞记录',
      icon: 'chat-heart-line',
    },
    children: [
      {
        path: 'like',
        name: 'like',
        component: () => import('@/views/like/index'),
        meta: {
          title: '点赞记录',
          icon: 'chat-heart-line',
        },
      },
    ],
  },
  {
    path: '/spider',
    component: Layout,
    redirect: '/spider',
    meta: {
      title: '规则管理',
      icon: 'bug-2-fill',
    },
    children: [
      {
        path: 'spider',
        name: 'spider',
        component: () => import('@/views/spider/index'),
        meta: {
          title: '规则管理',
          icon: 'bug-2-fill',
        },
      },
    ],
  },
  {
    path: '/magnet',
    component: Layout,
    redirect: '/magnet',
    meta: {
      title: '磁力管理',
      icon: 'attachment-2',
    },
    children: [
      {
        path: 'magnet',
        name: 'magnet',
        component: () => import('@/views/magnet/index'),
        meta: {
          title: '磁力管理',
          icon: 'attachment-2',
        },
      },
    ],
  },
  {
    path: '/menu',
    component: Layout,
    redirect: '/menu',
    meta: {
      title: '菜单管理',
      icon: 'menu-fill',
    },
    children: [
      {
        path: 'menu',
        name: 'menu',
        component: () => import('@/views/menu/index'),
        meta: {
          title: '菜单管理',
          icon: 'menu-fill',
        },
      },
    ],
  },
  {
    path: '/tags',
    component: Layout,
    redirect: '/tags',
    meta: {
      title: '标签',
      icon: 'price-tag-fill',
    },
    children: [
      {
        path: 'tags',
        name: 'tags',
        component: () => import('@/views/tags/index'),
        meta: {
          title: '标签管理',
          icon: 'price-tag-3-fill',
        },
      },
      {
        path: 'icon',
        name: 'Icon',
        component: () => import('@/views/vab/icon'),
        meta: {
          title: '图标',
          icon: 'remixicon-line',
        },
      },
    ],
  },
  {
    path: '/config',
    component: Layout,
    redirect: '/config',
    meta: {
      title: '参数管理',
      icon: 'settings-5-fill',
    },
    children: [
      {
        path: 'config',
        name: 'config',
        component: () => import('@/views/config/index'),
        meta: {
          title: '参数管理',
          icon: 'settings-5-line',
        },
      },
    ],
  },
  {
    path: '/*',
    redirect: '/404',
    hidden: true,
  },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
})

export default router
